/*
 * @lc app=leetcode.cn id=452 lang=java
 *
 * [452] 用最少数量的箭引爆气球
 */

// @lc code=start
class Solution {
    public int findMinArrowShots(int[][] points) {
        if (points.length == 0)
            return 0;
        Arrays.sort(points, new Comparator<int[]>() {
            public int compare(int[] point1, int[] point2) {
                if (point1[1] > point2[1]) {
                    return 1;
                } else if (point1[1] < point2[1]) {
                    return -1;
                } else {
                    return 0;
                }
            }

        });

        int count = 1;
        int end = points[0][1];
        for (int[] interval : points) {
            int start = interval[0];
            if (start > end) {
                count++;
                end = interval[1];
            }
        }
        return count;

    }
}
// @lc code=end
